document.addEventListener('DOMContentLoaded', function() {
    const praiseBtn = document.getElementById('praise-btn')
    const imageid = document.getElementById('mainimage').dataset.id
    praiseBtn.addEventListener('click', function() {
      fetch('/likeimage', {
        method: 'post',
        headers: new Headers([
          ['Content-Type', 'application/x-www-form-urlencoded']
        ]),
        body: 'imageid=' + imageid
      })
        .then(resp => resp.json())
        .then(image => {
          document.getElementById('spanlikes').textContent = image.likes
        })
    })
  })